//
//  VisitorViewController.swift
//  WB
//
//  Created by KenLiang on 16/4/7.
//  Copyright © 2016年 KenLiang. All rights reserved.
//

import UIKit

class BaseViewController: UITableViewController {

    // MARK:- 懒加载属性
    lazy var visitorView : VisitorView = VisitorView.visitorView()
    
    //设置变量
    var isLogin : Bool = true
    
    override func loadView() {
        isLogin ? super.loadView() : setupVisitorView()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupNavigationItems()
    }

}

// MARK:- 设置访客视图
extension BaseViewController {
    private func setupVisitorView() {
        view = visitorView
        //设置访客视图中的注册登录按钮点击
        visitorView.registerBtn.addTarget(self, action: "registerBtnClick", forControlEvents: .TouchUpInside)
        visitorView.loginBtn.addTarget(self, action: "loginBtnClick", forControlEvents: .TouchUpInside)
    }
    
    // 设置导航条的左右按钮点击
    private func setupNavigationItems() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "registerBtnClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "loginBtnClick")
    }
}

// MARK:- 监听按钮点击
extension BaseViewController {
   @objc private func registerBtnClick() {
        print("registerBtnClick")
    }
    
   @objc private func loginBtnClick() {
        print("loginBtnClick")
    }
}
